package day2.set.demo4_comparator;

import java.util.Comparator;
import java.util.TreeSet;

public class Test {
    public static void main(String[] args) {
        TreeSet<Emp> ts = new TreeSet<>(new Comparator<Emp>() {
            @Override
            public int compare(Emp o1, Emp o2) {
                return o1.age - o2.age;
            }
        });

        ts.add(new Emp("a1",23));
        ts.add(new Emp("a2",13));
        ts.add(new Emp("a3",17));

        for (Emp t : ts) {
            System.out.println(t);
        }
    }
}
